package metu.tespit.session.accountManagement;

import java.util.List;

import javax.persistence.EntityManager;

import metu.tespit.entitiy.accountManagement.User;

import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;

/**
 
 * @created May 21, 2012
 */

@Name("userConditionalList")
public class UserConditionalList 
{

	@In
	private EntityManager entityManager;


	@SuppressWarnings("unchecked")
	private List<User> getcondQuery(String condition){

		return entityManager.createQuery("Select u from User u where (Select ur from UserRole ur where ur.roleName=:role) member of u.userRoles")
		.setParameter("role", condition)
		.getResultList();

	}

	public List<User> getInstructorList(){

		return getcondQuery("Instructor");

	}
	public List<User> getStudentList(){

		return getcondQuery("Student");

	}

	public List<User> getTAList(){

		return getcondQuery("Teaching Assistant");

	}
}
